using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Tools;
using Pixysoft.Framework.Verifications;
using Pixysoft.Framework.Noebe;
using Pixysoft.Weblications.Sango.Entities;

namespace Pixysoft.Weblications.Sango.Environment
{
    public class CityStrategyHelper
    {
        private static List<Cti_Strategy> orms = new List<Cti_Strategy>();

        public static void initialize()
        {
            orms = SettingHelper.GetNoebe().EntityNoebeCommand.Select<Cti_Strategy>();

            LoggerHelper.Info("initialize Cti_Strategy.count:{0}", orms.Count);
        }

        public static Cti_Strategy searchStrategy(long typecode)
        {
            foreach (Cti_Strategy orm in orms)
            {
                if (orm.Strategytypecode == typecode)
                    return orm;
            }

            throw Exceptions.VerificationFailedException(typecode);
        }

        public static List<Cti_Strategy> searchOpenStrategies(long nextBuildingLevel)
        {
            List<Cti_Strategy> list = new List<Cti_Strategy>();

            foreach (Cti_Strategy orm in orms)
            {
                if (orm.Openlevel == nextBuildingLevel)
                    list.Add(orm);
            }

            return list;
        }

        public static List<Cti_Strategy> searchAll()
        {
            return orms;
        }
    }
}